package com.twu.biblioteca;

/**
 * Created by aswathik on 6/19/14.
 */
public class CheckOutMovie implements MenuItem {

    private Library library;
    private String menuString;

    CheckOutMovie(Library library) {
        this.library = library;
        menuString = "Check Out Movie";
    }

    public String getMenuString() {
        return menuString;
    }

    public MenuActionResult performMenuAction(UserInterface userInterface) {

        String movieTitle = userInterface.getMovieTitle();
        String movieDirector = userInterface.getMovieDirector();
        int yearOfRelease = userInterface.getMovieYearOfRelease();
        int rating = userInterface.getMovieRating();

        LibraryItem movieToCheckOut = new Movie(movieTitle,movieDirector,yearOfRelease,rating);

        MenuActionResult menuActionResult = new MenuActionResult();

        if (library.checkOut(movieToCheckOut)) {
            menuActionResult.setMenuActionDetails(true, "Enjoy your movie!!");
        } else {
            menuActionResult.setMenuActionDetails(false, "Sorry that movie is not available!");
        }
        userInterface.displayMenuActionResult(menuActionResult);
        return menuActionResult;

    }

}
